def myAtoi(s):
        """
        :type s: str
        :rtype: int
        """
        def truncate(num):
            if is_neg:
                num = -num
            max_val = 2 ** 31 - 1
            min_val = - 2 ** 31
            if num >= max_val:
                return max_val
            elif num <= min_val:
                return min_val
            return num

        s = s.strip()
        result = 0
        is_neg = False
        for i, char in enumerate(s):
            if char == '-' or char == '+':
                if i == 0:
                    if char == '-':
                        is_neg = True
                else:
                    return truncate(result)
            elif 0 <= ord(char) - ord('0') <= 9:
                result = result * 10 + ord(char) - ord('0')
            elif i == 0:
                return 0
            else:
                return truncate(result)
        return truncate(result)



def isNumber(self, s):
        """
        :type s: str
        :rtype: bool
        """
        has_exp = False
        has_dot = False
        has_sign = False
        has_num = False
        for i, char in enumerate(s):
            if char == '+' or char == '-':
                if i == len(s) - 1:
                    return False
                elif i == 0:
                    has_sign = True
                elif s[i-1] == 'e' or s[i-1] == 'E':
                    continue
                else:
                    return False
            elif char == 'e' or char == 'E':
                if has_exp:
                    return False
                elif i == 0 or i == len(s) - 1:
                    return False
                elif not has_num:
                    return False
                else:
                    has_exp = True
            elif char == '.':
                if has_dot or has_exp:
                    return False
                if i > 0:
                    if 0 <= ord(s[i-1]) - ord('0') <= 9 or s[i-1] == '-' or s[i-1] == '+':
                        has_dot = True
                    else:
                        return False
                elif i == 0:
                    has_dot = True
            elif 0 <= ord(char) - ord('0') <= 9:
                has_num = True
            else:
                return False
        return has_num
